/*
 * Copyright (c) 2005, the JUNG Project and the Regents of the University of
 * California All rights reserved.
 *
 * This software is open-source under the BSD license; see either "license.txt"
 * or http://jung.sourceforge.net/license.txt for a description.
 *
 * Created on Apr 14, 2005
 */

package com.davetrudes.jung.client.visualization.renderers;

import com.davetrudes.jung.client.graphics.Color;
import com.davetrudes.jung.client.graphics.Component;
import com.davetrudes.jung.client.graphics.Dimension;
import com.davetrudes.jung.client.graphics.Font;
import com.davetrudes.jung.client.graphics.component.JComponent;
import com.davetrudes.jung.client.graphics.component.Label;


/**
 * DefaultVertexLabelRenderer is similar to the cell renderers
 * used by the JTable and JTree jfc classes.
 *
 * @author Tom Nelson
 *
 *
 */
public class DefaultVertexLabelRenderer 
	implements VertexLabelRenderer {

     //protected static Border noFocusBorder = new EmptyBorder(0,0,0,0);

     protected Color pickedVertexLabelColor = Color.black;

    /**
     * Creates a default table cell renderer.
     */
    public DefaultVertexLabelRenderer(Color pickedVertexLabelColor) {
        this.pickedVertexLabelColor = pickedVertexLabelColor;
        //setOpaque(true);
        //setBorder(noFocusBorder);
    }


    /**
     *
     * Returns the default label renderer for a Vertex
     *
     * @param vv  the <code>VisualizationViewer</code> to render on
     * @param value  the value to assign to the label for
     *			<code>Vertex</code>
     * @param vertex  the <code>Vertex</code>
     * @return the default label renderer
     */
    public <V> Component getVertexLabelRendererComponent(JComponent vv, Object value,
            Font font, boolean isSelected, V vertex) {
    	Label l = new Label(new Dimension(0, 0));
        l.setForeground(vv.getForeground());
        if(isSelected) l.setForeground(pickedVertexLabelColor);
        l.setBackground(vv.getBackground());
        if(font != null) {
            l.setFont(font);
        } 
        //setBorder(noFocusBorder);
        l.setText((value == null) ? "" : value.toString());
        return l;
    }

}
